<?php
if (!defined('WEB_ROOT')) {
	exit;
}
if (isset($_GET['id']) && $_GET['id'] >0) {
	$id = (int)$_GET['id'];
	$queryString = "&id=$id";
} else {
	$id = 0;
	$queryString = '';
}

	
// for paging
// how many rows to show per page
$rowsPerPage = 5;

$sql = "SELECT bb.id, mabb, tenbb, tomtat_bb, date_format(ngaydang,'%d/%m/%Y') as ngaydang1, khoi_id, loaitc_id, tentc, impact_factor, tenloai, so, ngayra, tc_id
		FROM baibao bb join chitiet_tapchi cttc on bb.cttc_id = cttc.id join tapchi tc on cttc.tc_id = tc.id join loaitapchi ltc on tc.loaitc_id = ltc.id
		WHERE bb.hieu_luc = 1
		ORDER BY bb.id desc";
$result     = dbQuery(getPagingQuery($sql, $rowsPerPage));
$pagingLink = getPagingLink($sql, $rowsPerPage);
		
?> 
<div class="onecolumn">
				<div class="header">
					<span>Bài báo</span>
					<div class="switch" style="width:140px">
						<table width="140px" cellpadding="0" cellspacing="0">
						<tbody>
							<tr>
								<td>
									<input name="btnAddPaper" class="middle_switch" type="button" id="btnAddPaper" value="Thêm bài báo"  style="width:140px" onClick="addPaper()">
								</td>
							</tr>
						</tbody>
						</table>
					</div>
				</div>
				<br class="clear"/>
				<div class="content">
					<form action="processPaper.php?action=addPaper" method="post"  name="frmListPaper" id="frmListPaper">
					<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="data">
						  <tr align="center" id="listTableHeader"> 
							   <th width="200">Thông tin bài báo</th>
							   <th>Thông tin tạp chí</th>
						  </tr>
						  <?php
								if (dbNumRows($result) > 0) {
									$i = 0;
									while($row = dbFetchAssoc($result)) {
									extract($row);		
							if ($i%2) {
								$class = 'row1';
							} else {
								$class = 'row2';
							}
							$i += 1;
						?>
					  <tr class="<?php echo $class; ?>"> 
						   <td>
								<div class="info_detail_noimage">
									<ul>
										<li>Mã bài báo: &nbsp;<strong><?php echo $mabb; ?></strong></li>
										<li>Tên bài báo: &nbsp;<strong><a href="index.php?view=detail&id=<?php echo $id; ?>"><?php echo $tenbb; ?></strong></a></li>
										<li>Tác giả:&nbsp;<strong><?php echo $hotentg; ?></strong></li>
									</ul>
									<div class='action'>&nbsp;&nbsp;<a href="javascript:modifyPaper(<?php echo $id; ?>);">Sửa</a>&nbsp;&nbsp;|					&nbsp;&nbsp;<a href="javascript:deletePaper(<?php echo $id; ?>);">Xóa</a></div>
								</div>
							</td>
						   <td width="150px">
								<div>&nbsp;Tên tạp chí:&nbsp;<b><?php echo $tentc; ?></b></div>
								<div class="gach_chan"></div>
								<div>&nbsp;Loại tạp chí:&nbsp;&nbsp;<?php echo $tenloai; ?></div>
								<div>
									<table width = 100% border="0" align="center" cellpadding="0" cellspacing="0" >
										<tr>
											<td width = "60"><div>Số:&nbsp;&nbsp;&nbsp;<?php echo $so; ?></div></td>
											<td width = "150"><div>Ra ngày: &nbsp;&nbsp;&nbsp;<?php echo $ngayra; ?></div></td>
											<td><div>Impact factor: &nbsp;&nbsp;&nbsp;<?php echo $impact_factor; ?></div></td>
										<tr>
									</table>
								</div>
							</td>
					</tr>
					 
					  <?php
						} // end while
					?>
					  <tr> 
					   <td colspan="5" align="center">
					   <?php 
					echo $pagingLink;
					   ?></td>
					  </tr>
					<?php	
					} else {
					?>
					  <tr> 
					   <td colspan="5" align="center">Không có bài báo nào</td>
					  </tr>
					  <?php
					}
					?>
					  <tr> 
					   <td colspan="5">&nbsp;</td>
					  </tr>
					 </table>
					 <p>&nbsp;</p>
					</form>
				</div>
			</div>